//
//  UIColor.swift
//  CMKit
//
//  Created by travel on 2016/12/15.
//  Copyright © 2016年 covermedia. All rights reserved.
//

import UIKit


public extension UIColor {
    
    public class func cm_colorWithRGB(_ red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat = 1.0) -> UIColor {
        let base: CGFloat = 255.0
        return UIColor(red: red/base, green: green/base, blue: blue/base, alpha: alpha)
    }
    
    public class func cm_colorWithHex(_ hex: Int, alpha: Float = 1.0) -> UIColor {
        let blue = hex & 0xFF
        let green = (hex >> 8) & 0xFF
        let red = (hex >> 16) & 0xFF
        return self.cm_colorWithRGB(CGFloat(red), green: CGFloat(green), blue: CGFloat(blue), alpha: CGFloat(alpha))
    }
    
    public class func cm_colorWithHex(_ hex: Int, alphaHex: Int) -> UIColor {
        return self.cm_colorWithHex(hex, alpha: Float(alphaHex)/255.0)
    }
}
